package org.icnmasjid.member.webapp.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.icnmasjid.member.Constants;
import org.icnmasjid.member.model.Address;
import org.icnmasjid.member.service.Manager;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

public class AddressController implements Controller {
    private final Log log = LogFactory.getLog(AddressController.class);
    private Manager manager = null;

    public void setManager(Manager manager) {
        this.manager = manager;
    }

    public ModelAndView handleRequest(HttpServletRequest request,
                                      HttpServletResponse response)
    throws Exception {
        if (log.isDebugEnabled()) {
            log.debug("entering 'handleRequest' method...");
        }

        return new ModelAndView("addressList", Constants.ADDRESS_LIST,
                                manager.getObjects(Address.class));
    }
}
